import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from "../views/Home.vue"
import Recommend from '../views/Home/Recommend.vue'
import Rank from '../views/Home/Rank.vue'
import Search from '../views/Home/Search.vue'
import Songlist from '../views/Songlist.vue'
import Morelist from '../views/Morelist.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'Home',
    component: Home,
    // 通过重定向，将 / 重定向 到 /recommend ，实现默认显示推荐页
    redirect: '/recommend',
    //定义二级路由
    children: [
      {
        path: "recommend",
        name: 'Recommend',
        component: Recommend,
      },
      {
        path: "rank",
        name: 'Rank',
        component: Rank,
      },
      {
        path: "search",
        name: 'Search',
        component: Search,
      }
    ]
  },
  {
    path: '/songlist',
    name: 'Songlist',
    component: Songlist,
  },
  {
    path: '/morelist',
    name: 'Morelist',
    component: Morelist,
  },
]

const router = new VueRouter({
  routes
})

export default router
